
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

<title>Message Queue</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="docs.css">
</head>
<body>
<div class="container-fluid">
  <script src="menu.js"></script>
  <div class="content p-3">
    <div class="container-fluid">
      <h2>Message Queue</h2>
      <hr>
      <canvas id="message-queue" width="100" height="200"></canvas>

      <h5 class="mt-3">Html</h5>
  <pre><code><!-- Defalut view dimension 100 x 200. Flexible view width and height. -->
<canvas id="message-queue" width="100" height="200"></canvas></code></pre>

      <h5>JavaScript</h5>
<pre><code>/* Options */
var options = {
  // Bar height number.
  barHeight: 20,
  // Vertical space between two bars.
  space: 5,
  // Bar scolling speed.
  speed: 5,
  // The maximum number of elements can be hold in the queue.
  maxQueueCapacity: 30
};

/* Constructor */
var messageQueue = new zeu.MessageQueue('message-queue', options);

/* Getter */
// Get the number of elements in the queue.
var queueSize = messageQueue.queueSize;

/* Function */
// Push one element into the queue.
messageQueue.push({
  // Element color.
  color: '#17a2b9',
  // Control the size of the element. 0 is the largest.
  space: 0,
});

// Pop one element.
messageQueue.pop();</code></pre>

    <h4>More examples</h4>
    <p>
      Increase view width to 200, view height to 600 and push messages in random color and size.
    </p>
    <canvas id="message-queue-2" width="200" height="600"></canvas>
    </div>
  </div>
</div>

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/styles/github.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.4.0/highlight.min.js"></script>
<script src="docs.js"></script>
<script src="../dist/zeu.js"></script>
<script type="text/javascript">
/* Options */
var options = {
  barHeight: 20,
  space: 5,
  speed: 5,
  maxQueueCapacity: 30
};

/* Constructor */
var messageQueue = new zeu.MessageQueue('message-queue', options);

var messageQueue2 = new zeu.MessageQueue('message-queue-2', {
  viewWidth: 200,
  viewHeight: 600,
  barHeight: 15,
  space: 5,
  speed: 10,
  maxQueueCapacity: 100
});

setInterval(function() {
  messageQueue.push({
    color: '#17a2b9',
    space: 0,
  });

  messageQueue2.push({
    color: getRandomColor(),
    space: getRandomInt(0, 30)
  });
}, 200);

setInterval(function() {
  messageQueue.pop();
  messageQueue2.pop();
}, 500);

</script>
</body>
</html>

